//
//  FXTBaseViewController.m
//  OfferJob
//
//  Created by 郑州动力无限科技 on 2017/6/30.
//  Copyright © 2017年 郑州动力无限科技. All rights reserved.
//

#import "FXTBaseViewController.h"
#define  kMessageTag 1000
#define  kPicTag  1001
@interface FXTBaseViewController ()

@end

@implementation FXTBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor =[UIColor whiteColor];
    
    self.navigationController.navigationBar.translucent = NO;
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    [self dependOnKindToViewShow];
}
#pragma mark - Private Methods
-(void)dependOnKindToViewShow {
    CMNavType navType =[self getNavType];
    switch (navType) {
        case CMNavTypeNone:
            self.navigationController.navigationBar.hidden =YES;
            break;
        case CMNavTypeOnlyTitle:
            self.navigationController.navigationBar.hidden =NO;
            [self customNavigationTitleView];
            
            break;
        case CMNavTypeNoRightItem:
            self.navigationController.navigationBar.hidden =NO;
            [self customNavigationLeftItem];
            [self customNavigationTitleView];
            
            break;
        case CMNavTypeAll:
            self.navigationController.navigationBar.hidden =NO;
            [self customNavigationTitleView];
            [self customNavigationRighItem];
            [self customNavigationLeftItem];
            break;
        case CMNavTypeNoLeftItem:
            self.navigationController.navigationBar.hidden =NO;
            [self customNavigationTitleView];
            [self customNavigationRighItem];
            
        default:
            break;
    }
    
}


//定制导航栏上的titleView
- (void)customNavigationTitleView
{
    NSString *titleStr =[self customNavigationTitleViewTitleStr];
    UILabel *label = [FXTCustomViewFactory createLabel:CGRectMake(0, 5, 100, 34) title:titleStr color:[UIColor whiteColor] font:[UIFont systemFontOfSize:19 *kAppScale] textAlignment:NSTextAlignmentCenter];
    self.navigationItem.titleView = label;
}

//定制导航栏左边的按钮
- (void)customNavigationLeftItem
{
    UIButton *leftButton =[UIButton buttonWithType:UIButtonTypeCustom];
    leftButton.frame = CGRectMake(-10, 0, 30, 34);
    [leftButton setImage:[UIImage imageNamed:@"icon_fanhui"] forState:UIControlStateNormal];
    
    [leftButton addTarget:self action:@selector(navigationLeftButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithCustomView:leftButton];
    self.navigationItem.leftBarButtonItem = leftItem;
}

//定制导航栏右边的按钮
- (void)customNavigationRighItem
{
    NSString *titleStr =[self customNavigationRightItemTitle];
    
    UIButton * rightButton = [FXTCustomViewFactory  createButton:CGRectMake(0, 0, 60, 30) title:titleStr Image:[UIImage imageNamed:@"icon_rightItemBg"]];
    rightButton.titleLabel.font =[UIFont systemFontOfSize:15 *kAppScale];
    [rightButton setTitleColor:[UIColor darkTextColor] forState:UIControlStateHighlighted];
    [rightButton setBackgroundImage:[UIImage imageNamed:@"icon_rightItemBg"] forState:UIControlStateHighlighted];
    [rightButton setAdjustsImageWhenDisabled:NO];
    [rightButton addTarget:self action:@selector(navigationRightButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:rightButton];
    self.navigationItem.rightBarButtonItem = rightItem;
}
#pragma mark - 子类重写

-(CMNavType)getNavType {
    return CMNavTypeNoRightItem;
}

-(NSString *)customNavigationRightItemTitle {
    return @"设置";
}

-(NSString *)customNavigationTitleViewTitleStr {
    return self.title;
}
- (void)navigationLeftButtonClick:(id)sender
{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)navigationRightButtonClick:(id)sender
{
    
}


@end
